package ${package.Convertor};

import ${package.QueryRequest}.${QueryRequestName};
import ${package.SaveOrUpdateRequest}.${SaveOrUpdateRequestName};
import ${package.QueryResponse}.${QueryResponseName};
import com.pine.common.convertor.EntityConvertor;
import com.pine.common.convertor.QueryConvertor;
import com.pine.common.convertor.SaveConvertor;
<#list enumImportPackages as enumImportPackage>
import ${enumImportPackage};
</#list>
import ${package.Entity}.${EntityName};
import ${package.Bo}.${BoName};
import ${package.Query}.${QueryName};
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;

import java.util.Objects;

/**
 * <p>
 * ${table.comment!} 转换器
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public abstract class ${ConvertorName} implements EntityConvertor<${EntityName}, ${BoName}>,
        QueryConvertor<${BoName}, ${QueryName}, ${QueryRequestName}, ${QueryResponseName}>,
        SaveConvertor<${BoName}, ${SaveOrUpdateRequestName}> {

<#list enumConvertorInfos as enumConvertorInfo>
    public ${enumConvertorInfo.enumClassName} ${enumConvertorInfo.lowerFirstCharEnumCodeType}To${enumConvertorInfo.enumClassName}(${enumConvertorInfo.enumCodeType} code) {
        if (Objects.isNull(code)) {
            return null;
        }
        return ${enumConvertorInfo.enumClassName}.of(code);
    }

    public ${enumConvertorInfo.enumCodeType} ${enumConvertorInfo.lowerFirstCharEnumName}To${enumConvertorInfo.enumCodeType}(${enumConvertorInfo.enumClassName} ${enumConvertorInfo.lowerFirstCharEnumName}) {
        if (Objects.isNull(${enumConvertorInfo.lowerFirstCharEnumName})) {
            return null;
        }
        return ${enumConvertorInfo.lowerFirstCharEnumName}.getCode();
    }
</#list>
}
